package(default_visibility = ["//:__subpackages__"])

licenses(["notice"])

load("@tink_java//tools/build_defs:javac.bzl", "JAVACOPTS_OSS")

java_library(
    name = "libtinkey",
    srcs = glob(
        [
            "src/main/**/*.java",
        ],
        exclude = [
            "src/main/java/com/google/crypto/tink/tinkey/Tinkey.java",
        ],
    ),
    javacopts = JAVACOPTS_OSS,
    deps = [
        "@tink_java//:awskms",
        "@tink_java//:cleartext_keyset_handle",
        "@tink_java//:gcpkms",
        "@tink_java//:subtle",
        "@tink_java//src/main/java/com/google/crypto/tink",
        "@tink_java//src/main/java/com/google/crypto/tink:primitives",
        "@tink_java//src/main/java/com/google/crypto/tink/aead",
        "@tink_java//src/main/java/com/google/crypto/tink/daead",
        "@tink_java//src/main/java/com/google/crypto/tink/hybrid",
        "@tink_java//src/main/java/com/google/crypto/tink/mac",
        "@tink_java//src/main/java/com/google/crypto/tink/prf:prf_key_templates",
        "@tink_java//src/main/java/com/google/crypto/tink/signature",
        "@tink_java//src/main/java/com/google/crypto/tink/streamingaead",
        "@tink_java//proto:tink_java_proto",
        "@com_google_protobuf_javalite//:protobuf_javalite",
        "@maven//:args4j_args4j",
    ],
)

java_binary(
    name = "tinkey",
    srcs = [
        "src/main/java/com/google/crypto/tink/tinkey/Tinkey.java",
    ],
    javacopts = JAVACOPTS_OSS,
    main_class = "com.google.crypto.tink.tinkey.Tinkey",
    visibility = ["//testing:__subpackages__"],
    deps = [
        ":libtinkey",
        "@tink_java//src/main/java/com/google/crypto/tink/config",
        "@maven//:args4j_args4j",
    ],
)

# tests

load("@tink_java//tools:gen_java_test_rules.bzl", "gen_java_test_rules")

java_library(
    name = "generator_test",
    testonly = 1,
    srcs = glob([
        "src/test/**/*.java",
    ]),
    deps = [
        ":libtinkey",
        "@tink_java//:testonly",
        "@tink_java//:testutil",
        "@com_google_protobuf_javalite//:protobuf_javalite",
        "@maven//:com_google_truth_truth",
        "@maven//:junit_junit",
    ],
)

gen_java_test_rules(
    data = [
        "@tink_base//testdata:credentials",
    ],
    test_files = glob([
        "src/test/**/*Test.java",
    ]),
    deps = [
        ":generator_test",
    ],
)
